package com.shop.order.server.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: dpengpeng
 * Date: 2018/5/19
 * Time: 22:59
 * Description:
 */
@RestController
public class MessageTestController {

    private final RabbitTemplate rabbitTemplate;

    @Autowired
    public MessageTestController(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @GetMapping("send")
    public String sendMessage() {
        rabbitTemplate.convertAndSend("myEx", "computer", "时间" + new Date());
        return "ok";
    }

    @GetMapping("send1")
    public String sendMessage1() {
        rabbitTemplate.convertAndSend("myEx", "order", "时间" + new Date());
        return "ok";
    }
}
